﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PomTray
{
	public partial class NotificationDialog : Form
	{
		public NotificationDialog()
		{
			InitializeComponent();
		}

		public void SetMessage(string msg)
		{
			if (!this.IsHandleCreated)
			{
				this.lblMessage.Text = msg;
				return;
			}

			this.BeginInvoke((MethodInvoker) delegate  
			{
				this.lblMessage.Text = msg;
			});
		}

		public void ShowRestartButton(string label)
		{
			if (!this.IsHandleCreated)
			{
				this.btnRestart.Text = string.Format("Restart {0}", label);
				this.btnRestart.Visible = true;
				return;
			}

			this.BeginInvoke((MethodInvoker) delegate
			{
				this.btnRestart.Text = string.Format("Restart {0}", label);
				this.btnRestart.Visible = true;
			});
		}

		public void HideRestartButton()
		{
			if (!this.IsHandleCreated)
			{
				this.btnRestart.Visible = false;
				return;
			}

			this.BeginInvoke((MethodInvoker) delegate
			{
				this.btnRestart.Visible = false;
			});
		}

		public void InvokeClose()
		{
			this.Invoke((MethodInvoker) this.Close);
		}

		private void btnHide_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.OK;
			this.Close();
		}

		private void btnRestart_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Retry;
			this.Close();
		}
	}
}
